import router from './router' 
import pinia from "@/stores/store"
import { useUserStore } from '@/stores/user'   
// 白名单
const whiteList = ['/login']
/**
 * 路由前置守卫
 */ 

router.beforeEach(async (to, from, next) => { 
 
    const userStore = useUserStore(pinia)
    // 快捷访问 isLogin,userInfoState
    if (userStore.userid) {   
        next() 
    } else {
      // 没有token的情况下，可以进入白名单
      if (whiteList.indexOf(to.path) > -1) {
        next()
      } else {
        next('/login')
      }
    }
 
})
